package com.always.electrical.energy.utils;

import com.always.electrical.energy.mqtt.res.MqttResponse;
import com.always.electrical.energy.mqtt.res.MqttTaskRes;
import com.fasterxml.jackson.databind.JsonNode;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface JsonApi {

    @Nonnull
    String toJson(@Nullable Object data);

    @Nonnull
    <T> T fromJson(@Nullable String json, @Nonnull Class<T> clazz);

    @Nonnull
    <RES extends MqttResponse> MqttTaskRes<RES> fromJsonTypeRef(@Nullable String json, @Nonnull Class<RES> clazz);

    @Nonnull
    JsonNode readTree(@Nullable String json);
}
